package protobuf.netty.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import protobuf.entity.DataInfo;

public class TestServerHandler extends SimpleChannelInboundHandler<DataInfo.MyMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DataInfo.MyMessage msg) throws Exception {
        if(DataInfo.MyMessage.dataType.StudentType == msg.getDataType()){
            DataInfo.Student student = msg.getStudent();
            System.out.println(student.getName());
            System.out.println(student.getAge());
            System.out.println(student.getAddress());
        }else if(DataInfo.MyMessage.dataType.TeacherType == msg.getDataType()){
            DataInfo.Teacher teacher = msg.getTeacher();
            System.out.println(teacher.getName());
            System.out.println(teacher.getAge());
            System.out.println(teacher.getAddress());
        }else {
            DataInfo.Doctor doctor = msg.getDoctor();
            System.out.println(doctor.getName());
            System.out.println(doctor.getAge());
            System.out.println(doctor.getAddress());
        }
    }
}
